﻿/*************************************************************************
 * Created by OhZee Creative, LLC
 * 2013
 * This code is licensed under Microsoft Public License (Ms-PL)
 * http://opensource.org/licenses/ms-pl
 * http://ozframework.codeplex.com/
 *************************************************************************/

namespace OhZeeCreative.Xna
{
    using System;
    using System.Resources;
    using System.Windows;
    using System.Windows.Resources;
    using Microsoft.Xna.Framework.Audio;
    using OhZeeCreative.Sound.Core;

	public class SoundItem : ISoundItem
	{
		public SoundItem(string filename) : this (new Uri(filename, UriKind.RelativeOrAbsolute)) { }

		public SoundItem(Uri fileUri)
		{
			this.FileUri = fileUri;

			StreamResourceInfo resInfo = Application.GetResourceStream(this.FileUri);

			if (resInfo != null)
			{
				this.SoundEffect = SoundEffect.FromStream(resInfo.Stream);
				this.Duration = TimeSpan.FromSeconds(1.5);
			}
			else
			{
				this.Duration = TimeSpan.Zero;
			}
		}

		public void Stopped()
		{
		}

		public SoundEffect SoundEffect { get; private set; }


		public Uri FileUri { get; private set; }
		public TimeSpan Duration { get; private set; } 
	}
}
